/*
全局共公组件及方法
author:LiangShun
*/
import mergeTable from '@/components/mergeTable';//表格
import paging from '@/components/paging'//分页

export default {
  install(Vue) {
    /*共公组件*/
    Vue.component(mergeTable.name, mergeTable)
    Vue.component(paging.name, paging)

    /*共公方法*/
    //处理时间格式
    Vue.prototype.$getLocalTime = function (Time, status = false) {//参数1：时间，参数2：true当天的开始事件，false当天的结束时间
      const time = Time ? Time : new Date();
      const year = time.getFullYear();
      const month = (time.getMonth() + 1).toString().padStart(2, '0');
      const day = time.getDate().toString().padStart(2, '0');
      const hours = time.getHours().toString().padStart(2, '0');
      const minute = time.getMinutes().toString().padStart(2, '0');
      const second = time.getSeconds().toString().padStart(2, '0');
      if (Time) return `${year}-${month}-${day} ${hours}:${minute}:${second}`;
      if (status) return `${year}-${month}-${day} 00:00:00`;
      return `${year}-${month}-${day} 23:59:00`;
    }
    //处理同比环比时间格式
    Vue.prototype.$getOcerTime = function (Time, type = 'date') {//参数1：时间，参数2：true当天的开始事件，false当天的结束时间
      const time = Time ? Time : new Date();
      const year = time.getFullYear();
      const month = (time.getMonth() + 1).toString().padStart(2, '0');
      const day = time.getDate().toString().padStart(2, '0');
      if (type === 'date') return `${year}-${month}-${day}`
      if (type === 'month') return `${year}-${month}`
     
      // if (Time) return `${year}-${month}-${day} ${hours}:${minute}:${second}`;
    }
  }
}

